<?php
/**
 * NAME: admin
 * WHEN: OnMsg
 * PROVIDES: NONE
 * AUTOLOAD: true
 * DESCRIPTION: Funkcje dla opow i administratorow bota
 * VERSION: 0.1
 * UPDATE: http://update.tempaq2.blacksoft.eu/check.php
 * AUTHOR: blacksoft.eu
 */
 
 exit();
//*module_register_start
	$all = sqlite::fetchSQL('SELECT * FROM config WHERE id="channels"');
	/*$config = new table('config');
		$all = $config->select('id', 'channels');
	unset($config);*/
	$tab = array();
	if (is_array($all))
		foreach ($all as $v) 
			$tab[] = $v['value'];
	unset($all);
	//TODO: uncomment
	//$irc->join($tab);
	
//*function_start
	//TODO: dodawania i usuwanie kanałow na ktore ma wchodzić po wejsciu!
	if ($this->is_admin($data->nick)) {
		$dane = (isset($d[1]))?$d[1]:0;
		switch ($d[0]) {
			case '!autojoin':
				$bot->send($bot->lang->text('autojoining').(($bot->autojoin = ((!$bot->autojoin)?true:false))?'true':'false'));
				break;
			case '!join':
				if (!empty($dane)) {
					$irc->join(explode(" ", substr($message, strlen($d[0]))));
				}
				break;
			case '!leave':
				if (!empty($dane)) {
					$irc->part($dane, substr($message, strpos($message, $d[1])+strlen($d[1])+1));
				} elseif (!empty($data->channel)) {
					$irc->part($data->channel);
				}
				break;
			case '!nick':
				if (!empty($dane)) {
					$irc->changeNick($dane);
				}
				break;
			case '!op':
				if ($dane !== 0) {
					for($i=1; $i<count($d); $i++) {
						$irc->op($data->channel, $d[$i]);
					}
				} else
					$irc->op($data->channel, $data->nick);
				break;
			case '!deop':
				if (!empty($dane)) {
					$irc->deop($data->channel, $dane);
				} else $irc->deop($data->channel, $data->nick);
				break;
			case '!voice':
				if (!empty($dane)) {
					$irc->voice($data->channel, $dane);
				}
				break;
			case '!devoice':
				if (!empty($dane)) {
					$irc->devoice($data->channel, $dane);
				}
				break;
			case '!kick':
				if (!empty($dane)) {
					$irc->kick($data->channel, $dane, substr($message, strpos($message, $d[1])+strlen($d[1])+1));
				}
				break;
			case '!channels':
				$chan = $this->irc->channel;
				$msg = $this->lang->text('channels', count($chan))." ";
				foreach ($chan as $a) {
					$msg.=$a->name.' ';
				}
				$this->send($msg);
				break;
		}
	}
//*function_end	
?>